package com.pk.platform.business.core.web;

import com.pk.platform.business.core.service.IFormService;
import com.pk.platform.business.core.vo.FormVO;
import com.pk.platform.domain.form.FormDefine;
import com.pk.platform.domain.form.FormModule;
import com.pk.platform.util.StringConverter;

public class FormAction extends GenericAction {

	private FormModule fm = new FormModule();
	
	private FormDefine fd = new FormDefine();
	
	private FormVO fvo = new FormVO();
	
	private IFormService formService;
	
	public String formModuleManage()
	{
		super.initGrid();
		return "formModuleManage";
	}
	
	public String formDefineManage()
	{
		super.initGrid();
		return "formDefineManage";
	}
	
	public String toSaveFormModule()
	{
		if(StringConverter.isNotNull(fm.getId()))
		{
			fm = formService.queryFormModuleById(fm.getId());
		}
		return "toSaveFormModule";
	}
	
	public String toSaveFormDefine()
	{
		super.initGrid();
		if(StringConverter.isNotNull(fd.getId()))
		{
			fd = formService.queryFormDefineById(fd.getId());
			String formCode = fd.getFormCode();
			int index = formCode.lastIndexOf("_");
			String displayCode = formCode.substring(index + 1, formCode.length());
			fd.setFormCode(displayCode);
			fd.setFormContentStr(StringConverter.blobToString(fd.getFormContent()));
		}
		return "toSaveFormDefine";
	}
	
	public String saveFormModule()
	{
		message = formService.saveFormModule(fm);
		return "saveFormModule";
	}
	
	public String saveFormDefine()
	{
		message = formService.saveFormDefine(fd);
		return "saveFormDefine";
	}
	
	public String delFormModule()
	{
		message = formService.delFormModule(fm.getId());
		return "delFormModule";
	}
	
	public String delFormDefine()
	{
		formService.delFormDefine(fd.getId());
		return "delFormDefine";
	}
	

	public FormModule getFm() {
		return fm;
	}

	public void setFm(FormModule fm) {
		this.fm = fm;
	}

	public FormDefine getFd() {
		return fd;
	}

	public void setFd(FormDefine fd) {
		this.fd = fd;
	}

	public FormVO getFvo() {
		return fvo;
	}

	public void setFvo(FormVO fvo) {
		this.fvo = fvo;
	}

	public IFormService getFormService() {
		return formService;
	}

	public void setFormService(IFormService formService) {
		this.formService = formService;
	}
	
}
